 <meta charset="utf-8">
 <div class="row" id="biz_authMenu_conatainer">
 <div class="col-lg-2 col-md-2 col-sm-3">
 		<div class="panel panel-default">
			<div class="panel-heading">菜单树展示</div>
			<div class="panel-body" id="authMenuTreeDiv">
				<ul id="menuTreeShow" v-ktree="{url:'auth/authMenu/loadAuthMenuTree',chkEnable:false,chkStyle:'checkbox'}" class="ztree"></ul>
				
			</div>
		</div>
 </div>
 
 <div class="col-lg-10 col-md-10 col-sm-9">
	  <div class="box" >
	       <div class="box-header with-border">
	               <form id="searchForm" role="form" class="form-inline">
	                    <div class="form-group">
	                         <label>菜单名称</label>
	                         <input name="name" v-model="searchForm.name"    type="text" placeholder="" class="form-control">
	                    </div>
		                  <div class="form-group" >
						 <label>所属应用</label>
							 <select id="appKey" name="appKey" v-model="searchForm.appKey"   
							    v-kselect="{url:'auth/authApp/loadAuthAppComboboVo',vmodel:'searchForm.appKey',firstEmpty:'true'}" class=" form-control"> </select>
						</div>
					
						 <div class="form-group" >
						 <label>所属模块</label>
							 <select id="moduleId"  name="moduleId" v-model="searchForm.moduleId" 
							    v-kselect="{url:'auth/authModule/loadModuleComboboVo',vmodel:'searchForm.moduleId',linkToDomId:'appKey',ajaxParamKey:'appKey',firstEmpty:'true'}" class=" form-control"> </select>
						</div>  
	              
	                  <button type="button"  class="btn btn-info pull-right m-t-n-xs" v-kperms="{perm:'authPermission:loadAuthPermissionList'}" v-on:click="search"><strong>查询</strong></button>
	                </form>
	        </div>
		 <div class="box-body">
		 	<div class="row">
		 	  <div class="col-md-12">
		 	                       <div class="btn-group " id="authMenuTableToolbar" role="group">
		 	                       			<button type="button" v-kperms="{perm:''}"  class="btn btn-default" v-on:click="add">
		                                        <i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 添加
		                                    </button>
		                                    
		                                     <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="edit">
		                                        <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 修改
		                                    </button>
		                                  
		                                    <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="deletex">
		                                        <i class="glyphicon glyphicon-trash" aria-hidden="true"></i> 删除
		                                    </button>
		                                     <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="setEnable">
		                                        <i class="glyphicon glyphicon-ok" aria-hidden="true"></i> 启用
		                                    </button>
		                                     <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="setDisable">
		                                        <i class="glyphicon glyphicon-remove" aria-hidden="true"></i> 禁用
		                                    </button>
		                           </div>
		                                
		           <table id="ahthMenuBootstrapTable" data-mobile-responsive="true" ></table>
		 	  </div>
		 	</div>
		 </div>
	 </div>
 </div>
 </div>
<script>
new Vue({  
	  el: '#biz_authMenu_conatainer',
	  data:{
		  searchForm:{
			  name: null,
			  appKey: null,
			  moduleId: null
		  },
		  bus:new Vue()
	  },
	  mounted:function(){
		 let _this=this;
		 _this.bus.$on(zfesVueDirective.getKselectOnInitEventName("appKey"), function (msg) {
				_this.initTable();
		 });
	  },
    methods: {
  	  initTable:function(){
  		 let _this=this;
  		  let columns=[
  					{checkbox:true},
  					{field:'name',title:'菜单名称',width:160,sortable:true},
					{field:'type',title:'类型',width:60,formatter:_this.formatType},
					{field:'permName',title:'对应权限',width:100},
					{field:'appName',title:'所属应用',width:80},
					{field:'moduleName',title:'所属模块',width:80},
					{field:'enabled',title:'是否启用',width:60,formatter:zfesUtil.formatEnabled},
					{field:'iconcls',title:'显示图标',width:100},
					{field:'description',title:'备注',width:160}];
  		  let url="auth/authMenu/loadAuthMenuList";
    		zfesBstable.laodTable($("#ahthMenuBootstrapTable"),$("#searchForm"),$("#authMenuTableToolbar"),url,columns,this.searchForm);
  	  },
  	  search:function(){
  		  this.getCheckedNodes();
  		  zfesBstable.reload($("#ahthMenuBootstrapTable")); 
  	  },
  	  refresh:function(){
  		  zfesBstable.refresh($("#ahthMenuBootstrapTable"));
  	  },
  	  add:function(){
  		  let　_this=this;
  		 var url="/view/auth/authMenu/authMenu.add.html";
  		 zfesLayerEditDg.open(url,{},"菜单信息编辑",660,function(){_this.refresh();});
  		 
  	  },
  	  edit:function(){
  		  if(zfesBstable.isOneRow($("#ahthMenuBootstrapTable"))){
  			  let　_this=this;
  			  let id=zfesBstable.getRowId($("#ahthMenuBootstrapTable"));
  			  let url="/view/auth/authMenu/authMenu.edit.html";
  			  zfesLayerEditDg.open(url,{"id":id},"菜单信息编辑",600,function(){_this.refresh();}); 
  		 }
  	  },
  	  setEnable:function(){
  		  if(zfesBstable.isSelectedRow($("#ahthMenuBootstrapTable"))){
  			  let ids=zfesBstable.getRowIds($("#ahthMenuBootstrapTable"));
  			  let　_this=this;
  				 alertSwal.confirm("启用","是否执行该操作",function(){
						    let ajaxUrl = "auth/authMenu/setAuthMenuEnabled";
						    zfesAjax.ajaxTodo(ajaxUrl, { "ids" : ids,"enabled":true}, function(data) {
								alertSwal.successText(data.message);
								_this.refresh();
							});
						});
  		  }
  	  },
  	  setDisable:function(){
  		  if(zfesBstable.isSelectedRow($("#ahthMenuBootstrapTable"))){
  			  let ids=zfesBstable.getRowIds($("#ahthMenuBootstrapTable"));
  			  let　_this=this;
  				 alertSwal.confirm("禁用","是否执行该操作",function(){
						    let ajaxUrl = "auth/authMenu/setAuthMenuEnabled";
						    zfesAjax.ajaxTodo(ajaxUrl, { "ids" : ids,"enabled":false}, function(data) {
								alertSwal.successText(data.message);
								_this.refresh();
						});
  		  		});
  		  }
  	  },
  	  deletex:function(){
  			if(zfesBstable.isSelectedRow($("#ahthMenuBootstrapTable"))){
  				  let　_this=this;
  					let ids=zfesBstable.getRowIds($("#ahthMenuBootstrapTable"));
  					 alertSwal.confirm("删除","是否删除该菜单",function(){
  						    let ajaxUrl = "auth/authMenu/removeAuthMenu";
  							zfesAjax.ajaxTodo(ajaxUrl, { "ids" : ids}, function(data) {
  								alertSwal.successText(data.message);
  								_this.refresh();
  							}); 
  				});
  			}
  				
  	  },
  	  formatType:function(value, row, index){
  		if("G"==value){return '[分组]';}else if("M"==value){return '[菜单]';}else{return value;}
  	}
   	
   }

});
</script>


